Best practices for prompt engineering with OpenAI API
https://help.openai.com/en/articles/6654000-best-practices-for-prompt-engineering-with-openai-api
講義で言ってた「分析対象テキストをChatGPTに分析対象であると認識させる」はめちゃ重要で、具体的には下記Rule of Thumbの2みたいに書くのだけれども、これやらないとChatGPTがそのテキストをユーザーの指示と間違えることがあり、自分はやってなくてハマったことがある。 で知った
How to give clear and effective instructions to GPT-3 and Codex
IMO:ChatGPT Prompt Engineering for Developersよりも古いかも
日本語で解説!Best practices for prompt engineering with OpenAI API
Rules of Thumb and Examples
1. Use the latest model
2. Put instructions at the beginning of the prompt and use ### or """ to separate the instruction and context
デリミタの使用
3. Be specific, descriptive and as detailed as possible about the desired context, outcome, length, format, style, etc
「Write a poem」ではなく、具体的にfocusingなどを伝える例
4. Articulate the desired output format through examples
Show, and tell
Extract the important entities mentioned in the text below. First extract all company names, then extract all people names, then extract specific topics which fit the content and finally extract general overarching themes
Desired formatも指定している
5. Start with zero-shot, then few-shot, neither of them worked, then fine-tune
「zero-shotで始め、次にfew-shot、いずれも機能しなければfine-tune」
Extract keywords from the corresponding texts below.
few-shotの例がある
6. Reduce “fluffy” and imprecise descriptions
Use a 3 to 5 sentence paragraph
7. Instead of just saying what not to do, say what to do instead
「すべきでないことの代わりに、すべきこと」
IMO:否定に弱い?
8. Code Generation Specific - Use “leading words” to nudge the model toward a particular pattern
Additional Resources(積ん読)